TomatoBreak = @TomatoBreak

class Session extends Spine.Model

    @configure 'Session', 'emailOrUserName', 'password', 'rememberMe'

    @extend Spine.Model.Ajax

    @extend { url: -> 'session' }

    validate: ->

        errors = []

        addError = (name, message) ->
            error = { name: name, messages: [] }
            error.messages.push message
            errors.push error

        addError 'emailOrUserName', 'Email or User name cannot be blank.' unless @emailOrUserName
        addError 'password', 'Password cannot be blank.' unless @password

        errors if errors.length

TomatoBreak.Session = Session